<!-- 记录用工 -->
<template>
	<div>
		<text class="form-title">农事用工信息</text>
		<empRecordForm :formInline="formInline" :formItem="formItem" @changePicker="changePicker" @getImgArr="getImgArr"></empRecordForm>
	</div>

</template>

<script>
	import empRecordForm from "../../components/current/vForm.vue";

	export default {
		components: {
			empRecordForm
		},
		data() {
			return {
				//表格参数
				formItem: [{
						type: 'picker',
						pickerType: '',
						label: "员工姓名",
						placeholder: "请选择员工姓名",
						array: ['员工第一个', '第二个', '第三个'],
						index: "",
						clumn: 'empName'
					},{
						type: 'picker',
						pickerType: '',
						label: "操作类别",
						placeholder: "请选择操作类别",
						array: ['操作第一个', '第二个', '第三个'],
						index: "",
						clumn: 'manipulateType'
					},{
						type: 'picker',
						pickerType: '',
						label: "基地名称",
						placeholder: "请选择基地名称",
						array: ['基地第一个', '第二个', '第三个'],
						index: "",
						clumn: 'baseName'
					},{
						type: 'radio',
						label: "计工类型",
						options: [{
							index: '1',
							value: '1',
							text: '天',
							checked: 'checked'
						}, {
							index: '2',
							value: '2',
							text: '小时',
						}],
						clumn: 'timeType'
					},{
						type: 'picker',
						pickerType: 'date',
						label: "开始时间",
						placeholder: "请选择开始时间",
						index: '',
						clumn: 'startTime'
					},{
						type: 'picker',
						pickerType: 'date',
						label: "结束时间",
						placeholder: "请选择结束时间",
						index: '',
						clumn: 'endTime'
					},{
						type: 'textarea',
						placeholder: "请输入详细内容",
						clumn: 'detailInfo'
					}
				],
				//表单字段数据
				formInline: {
					empName: "",
					manipulateType: "",
					baseName: "",
					timeType: "",
					startTime: "",
					endTime: "",
					detailInfo: "",
				},
			}
		},

		methods: {
			// 选择器发生改变时
			changePicker(i, clumn, value) {
				// 普通选择器赋值
				if (this.formItem[i].pickerType == '' || this.formItem[i].pickerType == 'selector') {
					this.formInline[clumn] = this.formItem[i].array[value];
					return
				}
				//时间选择器赋值
				if (this.formItem[i].pickerType == 'date') {
					this.formInline[clumn] = value;
					console.log("-------"+this.formInline[clumn])
					return
				}
			},
			
			// 接收上传图片路径并赋值
			getImgArr(i, clumn, value){
				this.formInline[clumn] = value;
			}
			
		}
	}
</script>

<style>
	.form-title {
		padding: 0 5%;
		color: rgb(136, 136, 136);
		line-height: 60rpx;
	}

</style>
